package com.luyou.a05;

import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.context.annotation.ConfigurationClassPostProcessor;
import org.springframework.context.support.GenericApplicationContext;

/**
 * BeanFactory
 */
public class A05Application {

    public static void main(String[] args) {
        GenericApplicationContext context = new GenericApplicationContext();
        context.registerBean("config", Config.class);
        //常见BeanFactory后置处理器
        // BeanFactory后置处理器 @ComponentScan @Bean @Import @ImportResource
//        context.registerBean(ConfigurationClassPostProcessor.class);
//
//        // @Mapper 必须是接口
//        context.registerBean(MapperScannerConfigurer.class, i ->{
//            i.getPropertyValues().add("basePackage", "com.luyou.a05.mapper");
//        });
        //常见BeanFactory后置处理器

        //实现@ComponentScan 注解的解析：
//        context.registerBean(ComponentScanPostProcessor.class);

        //实现@Bean注解
        context.registerBean(AtBeanPostProcessor.class);
        //实现@Mapper注解
        context.registerBean(MapperPostProcessor.class);
        context.refresh();

        for (String beanDefinitionName : context.getBeanDefinitionNames()) {
            System.out.println(beanDefinitionName);
        }

        context.close();

    }
}
